<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/home/include/init_home.jsp" %>
<%
	String job_type		= StringUtil.nvl(request.getParameter("job_type"), "C");
	String board_id 	= StringUtil.nvl(request.getParameter("board_id"));
	String word_id			= StringUtil.nvl(request.getParameter("word_id"));
	String password			= StringUtil.nvl(request.getParameter("password"));

	HashMap infos = new HashMap();
	infos.put("word_id",		word_id);


	BoardDAO boardDAO 		= new BoardDAO();
	HashList wordList		= boardDAO.selectWordDetail(infos);

	String action = "";
	String subject 	= "";
	String author_name	= "";
	String email = "";
	String telephone = "";

	if ("R".equals(job_type)) {
		action = "./wordInsert.do";
		subject = "RE:" + wordList.get("subject",0);
	} else if ("U".equals(job_type)){
		action = "./wordUpdate.do";
		subject = wordList.get("subject",0);
		author_name = wordList.get("author_name", 0);
		email = wordList.get("email", 0);
		telephone = wordList.get("telephone", 0);
	} else {
		action = "./wordInsert.do";
	}


	if ("U".equals(job_type) && !password.equals(wordList.get("password",0))) {
%>
		<script>
			alert("비밀번호가 일치하지 않습니다.")
			history.back(-1);
		</script>
<%		return;
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><%= HOME_NAME %></title>

	<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="/js/common2.js" charset="utf-8"></script>
	<script type="text/javascript" src="/js/ajaxfileupload.js"></script>
	<script type="text/javascript" src="/SE2.3.1.O9858/js/HuskyEZCreator.js" charset="utf-8"></script>
	<link href="../css/home.css" rel="stylesheet" type="text/css">

	<script type="text/javascript">
	var oEditors = [];

	$(document).ready(function() {
		cfInitSE("content_<%=board_id%>");
	});

	function fnSave() {
		if (document.saveForm.subject.value == "") {
			alert("제목을 입력하세요");
			document.saveForm.subject.focus();
			return false;
		}

		if (document.saveForm.author_name.value == "") {
			alert("글쓴이를 입력하세요");
			document.saveForm.author_name.focus();
			return false;
		}

		if (document.saveForm.password.value == "") {
			alert("비밀번호를 입력하세요");
			document.saveForm.password.focus();
			return false;
		}

		oEditors.getById["content_<%=board_id%>"].exec("UPDATE_CONTENTS_FIELD", []);

		document.saveForm.submit();
	}


	</script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <%@ include file="/home/include/top_menu.jsp" %>
  <tr>
    <td valign="top" align="center" class="sub_con"><table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
      <!--좌측네비 시작-->
        <%@ include file="/home/include/left_menu.jsp" %>
        <!--좌측네비 끝-->
        <td width="50"></td>
        <!--컨텐츠 시작-->
        <td valign="top" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><img src="../images/sub/08_title_01.gif" alt="커뮤니티" width="122" height="31" /></td>
                <td align="right" valign="bottom"></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td height="5"><img src="../images/sub/sub_line.gif" width="723" height="5" /></td>
          </tr>
          <tr>
            <td height="30"></td>
          </tr>
          <tr>
            <td class="sub_title"><%= menu_name %></td>
          </tr>
          <tr>
            <td height="40" align="right" valign="bottom">
            	* 이메일과 연락처는 관리자에게만 보입니다
            </td>
          </tr>
          <tr>
            <td valign="top">

            <form name="saveForm" action="<%= action %>" method="post" >
			<input type="hidden" name="job_type" value="<%= job_type %>"/>
            <input type="hidden" name="board_id" value="<%= board_id %>"/>
            <input type="hidden" name="word_id" value="<%= word_id %>"/>
			<input type="hidden" name="menu_id" value="<%= menu_id %>"/>
			<input type="hidden" name="pmenu_id" value="<%= pmenu_id %>"/>

	    	<input type="hidden" name="word_num" value="<%= wordList.get("word_num",0) %>">
	    	<input type="hidden" name="sort" value="<%= wordList.get("sort",0) %>">
	    	<input type="hidden" name="depth" value="<%= wordList.get("depth",0) %>">

            <table width="720" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td height="2" bgcolor="#999999"></td>
              </tr>
              <tr height="30">
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <th width="103" align="center">제목</th>
                    <td align="left" valign="middle">
                    	<input type="text" name="subject" style="width:610px;" class="input2" value="<%= subject %>">
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td height="1" bgcolor="#cccccc"></td>
              </tr>
              <tr height="30">
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr height="31">
                    <th width="103" align="center">글쓴이</th>
                    <td align="left" valign="middle">
                    	<input type="text" name="author_name" style="width:200px;" class="input2" value="<%= author_name %>">
                    </td>
                    <th width="103" align="center">비밀번호</th>
                    <td align="left" valign="middle">
                    	<input type="password" name="password" style="width:200px;" class="input2" >
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td height="1" bgcolor="#cccccc"></td>
              </tr>
              <tr height="30">
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr height="31">
                    <th width="103" align="center">이메일</th>
                    <td align="left" valign="middle">
                    	<input type="text" name="email" style="width:200px;" class="input2" value="<%=email %>">
                    </td>
                    <th width="103" align="center">연락처</th>
                    <td align="left" valign="middle">
                    	<input type="text" name="telephone" style="width:200px;" class="input2" value="<%=telephone %>">
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td height="1" bgcolor="#cccccc"></td>
              </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <th width="103" valign="top" style="padding-top:8px" align="center">내용</th>
                    <td align="left" style="padding-top:5px; padding-bottom:5px" >
						<textarea name="content" id="content_<%=board_id%>" style="width:100%; height:400px;" ><%=wordList.get("content",0)%></textarea>
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td height="1" bgcolor="#999999"></td>
              </tr>
              <tr>
                <td height="30"></td>
              </tr>
              <tr>
                <td align="center"><table width="145" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="71">
						<a href="#nohref" onclick="fnSave()"><img src="../images/sub/complete.gif" alt="완료" width="71" height="21" /></a>
					</td>
                    <td width="3"></td>
                    <td width="71"><a href="./boardList.jsp?board_id=<%=board_id %>&pmenu_id=<%=pmenu_id%>&menu_id=<%=menu_id %>"><img src="../images/sub/cancel.gif" alt="취소" width="71" height="21" /></a></td>
                  </tr>
                </table></td>
              </tr>
            </table>
            </form>



            </td>
          </tr>
          <tr>
            <td height="80"></td>
          </tr>
        </table></td>
        <!--컨텐츠 끝-->
      </tr>
    </table></td>
  </tr>
  <%@ include file="/home/include/footer.jsp" %>
</table>
</body>
</html>

